package cn.ld.module.system.dal.mapper.mail;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.system.controller.admin.mail.vo.log.MailLogPageInVO;
import cn.ld.module.system.dal.entity.mail.MailLogEntity;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface MailLogMapper extends BaseMapperX<MailLogEntity> {

    default PageResult<MailLogEntity> selectPage(MailLogPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<MailLogEntity>()
                .eqIfPresent(MailLogEntity::getUserId, inVO.getUserId())
                .eqIfPresent(MailLogEntity::getUserType, inVO.getUserType())
                .likeIfPresent(MailLogEntity::getToMail, inVO.getToMail())
                .eqIfPresent(MailLogEntity::getAccountId, inVO.getAccountId())
                .eqIfPresent(MailLogEntity::getTemplateId, inVO.getTemplateId())
                .eqIfPresent(MailLogEntity::getSendStatus, inVO.getSendStatus())
                .betweenIfPresent(MailLogEntity::getSendTime, inVO.getSendTime())
                .orderByDesc(MailLogEntity::getId));
    }

}
